/**
 * 函数节流
 * @param method
 * @param delay
 * @returns {Function}
 */
let timer = null
export function throttle (method, delay){
    let context = this
    let args = arguments

    clearTimeout(timer);
    timer = setTimeout(() => {
        method.apply(context, args)
    }, delay || 300)
}

export function sleep (delay){
    return new Promise((resolve, reject) => {
        setTimeout(() => {
            resolve()
        }, delay || 300)
    })
}


